/* 
 * The Start up Controller
 * 13/6/2013
 */
$(function() {

    var logininforSelector = "#pagehead-LoginInfo";
    $(logininforSelector).hide();

    // After login into the System, an alert will be show when leave the page
    window.onbeforeunload = function() {
        if (CPS.getSessionID().length > 1) {
            return("The unfinished operation will be lost");
        }
    };

    // add the login button
    var parentContainerSelector = "#Index_West";
    $(parentContainerSelector).panel({
        content: "<a id='btn_login' style=' margin-left: 50px;'>Login</a>"
    });
    $("#btn_login").click(function() {
        CPS.popUpCheckLogin();
    }).linkbutton({
        iconCls: 'icon-add'
    });

    // handle the Http GET Method
    var urlParameters = CPS.getUrlParmeters();
    Trace.debugJsObject(urlParameters);
    if (typeof urlParameters.UserID !== "undefined" && urlParameters.UserID.length > 0)
    {
        CPS.directCheckLogin(urlParameters.UserID);
    }
    return;
});
